package cn.yu.takeoutbackend.Notification.service;

import cn.yu.takeoutbackend.Notification.dao.NotificationRecordDao;
import cn.yu.takeoutbackend.Notification.entity.NotificationRecord;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class NotificationRecordRepository {
    @Autowired
    private NotificationRecordDao notificationRecordDao;
    public NotificationRecord findByBizTypeAndBizId(String bizType, String bizId) {
        final QueryWrapper<NotificationRecord> wrapper = new QueryWrapper<>();
        wrapper.eq("biz_type", bizType);
        wrapper.eq("biz_id", bizId);
        return notificationRecordDao.selectOne(wrapper);
    }

    public void save(NotificationRecord record) {
        notificationRecordDao.insert(record);
    }

    public void update(NotificationRecord record) {
        notificationRecordDao.updateById(record);
    }
}
